import React from 'react'
import { TextLine, TextCell, Split, TitleLine } from '@components/ApprovePre/Approve'
import { formatDate } from '@src/assets/js/tool'
import { download } from '@js/downloadRename'

// 渲染文件链接
function Links ({ list }) {
  if (!list) {
    return '无'
  }
  return list.map((li, i) => {
    return <a style={{ marginRight: '8px' }} key={i} onClick={() => download(li.path, li.original_filename)}>{li.original_filename}</a>
  })
}

function Main ({ data: d }) {
  return (
    <div>
      <TitleLine title='提交庭审笔录' operator={d.operator} time={formatDate(d.create_datetime)} />
      <TextLine>
        <TextCell>提交人：{d.operator || '无'}</TextCell>
        <Split />
        <TextCell>庭审笔录：<Links list={d.file} /></TextCell>
        <Split />
        <TextCell>备注：{d.content || '无'}</TextCell>
      </TextLine>
    </div>
  )
}

export default Main
